﻿Shader "Dan/UI/UI_BarGraph_Radius"
{
    Properties
    {
        _Color1 ("Color1", Color) = (0,0.5,1,1)
        _Color2 ("Color2", Color) = (1,0,0,1)
        _Emission ("Emission", Float ) = 1
        _EmissionRamp ("EmissionRamp", Range(0, 1)) = 0.5
        _Density ("Density", Float ) = 64
        _Width ("Width", Range(0, 1)) = 0.5
        _Length ("Length", Range(0, 1)) = 0.75
        _LengthContrast ("LengthContrast", Range(0, 1)) = 0.1
        _Mask ("Mask", Range(0, 1)) = 0.5
        _RandomSpeed ("RandomSpeed", Float ) = 1
        
        
    }
    SubShader
    {
        Tags {  "Queue"="Transparent" "RenderType"="Transparent" }
        LOD 100

        Pass
        {
            
            Tags { "LightMode"="ForwardBase"}
            Blend SrcAlpha OneMinusSrcAlpha
            ZWrite Off       
            
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            

            #include "UnityCG.cginc"
            #include "../ShaderLibs/UIFX.cginc"
            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            

             float _Mask;

             float _Width;
             float _Length;
             float _Density;
             float4 _Color1;
             float4 _Color2;
             float _Emission;
             float _EmissionRamp;
             float _RandomSpeed;
             float _LengthContrast;
            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
               
                return o;
            }

            
            fixed4 frag (v2f i) : SV_Target
            {
                
                float2 uv = i.uv*2.0-1.0;
                float circle = length(uv);
                float barStyle = (atan2(uv.x,uv.y)/6.7825)+0.5;
                
                BarGraph(circle,barStyle,_Density,_RandomSpeed,_LengthContrast,_Length,_Width,_Mask);
                float3 finalColor = lerp(_Color1.rgb,_Color2.rgb,_EmissionRamp*circle)*_Emission;
                return fixed4(finalColor,1);


            }
            ENDCG
        }
    }
}
